// Learn cc.Class:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/class/index.html
// Learn Attribute:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/reference/attributes/index.html
// Learn life-cycle callbacks:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/life-cycle-callbacks/index.html

cc.Class({
    extends: cc.Component,

    properties: {
        spHead:cc.Sprite,

        spHeadBase:cc.SpriteFrame,

        labName:cc.Label,

        labMoney:cc.Label,

        labIssue:cc.Label,

        labLottyerName:cc.Label,

        ndChese:cc.Node,

        _data:null,  //数据信息
    },

    // use this for initialization
    onLoad: function () {
        if(this._data != null)
        {
            //cc.log("chatbet head:" + this._data.head);
            if(this._data.head != "" && typeof(this._data.head) != "undefined" && this._data.head !=null){
                cc.loader.load(this._data.head, function(err, tex){
                    //cc.log("err :"+ err+" init my logo3:"+tex);
                    if(tex != null){
                        var sf = new cc.SpriteFrame(tex);
                        this.spHead.spriteFrame = sf;
                        this.spHead.node.width = 127;
                        this.spHead.node.height = 127;
                    }
                    else
                    {
                        this.spHead.spriteFrame = this.spHeadBase;
                    }
                }.bind(this));
            } 
            else
            {
                this.spHead.spriteFrame = this.spHeadBase;
            }
            this.labName.string = this._data.name;
            this.labMoney.string = "投注金额：" + this._data.money + " 元宝";
            this.labIssue.string = this._data.isuse + " 期";
            this.labLottyerName.string = "类型：" + this._data.lotteryName;
            //this.ndChese.active = this._data.buttype == 1?true:false;
        }
    },

    init:function(data){
        this._data = data;
    },
    
});
